using UnityEngine.U2D;
/// <summary>
/// AssetBundle资源管理器
/// </summary>
public partial class HFABMgr : AbsHFSingleMonoBehaviour<HFABMgr>
{
    /// <summary>
    /// OnInitSpriteAtlas
    /// </summary>
    void OnInitSpriteAtlas()
    {
        base.OnAfterCreateInstance();        
        SpriteAtlasManager.atlasRequested += SpriteAtlasManager_atlasRequested;
    }

    /// <summary>
    /// 图集请求
    /// </summary>
    /// <param name="_spriteAtlasName">SpriteAtlas名称</param>
    /// <param name="_callback">回调</param>
    private void SpriteAtlasManager_atlasRequested(string _spriteAtlasName, System.Action<SpriteAtlas> _callback)
    {
        HFSpriteAtlas_AssetBundleAttribute ab = HFGlobal_SpriteAtlas.Instance.GetSpriteAtlasPath(_spriteAtlasName);
        if (ab != null)
        {
            OnLoadInMemory(ab, (rsp,args) =>
            {
                SpriteAtlas sa = rsp.GetAsset<SpriteAtlas>();
                System.Action<SpriteAtlas> call = (System.Action<SpriteAtlas>)args[0];
                call?.Invoke(sa);
            }, null, null, null, null,_callback);
        }
        else
        {
            HFP.HFError($"SpriteAtlasManager_atlasRequested=> Can't find SpriteAtlas {_spriteAtlasName}");
        }
    }
}
